Fleetrun
Hecterra
NimBus
Other apps
Wialon for Android/iOS
Logistics
Wialon Local
Wialon Hosting
WiaTag
Configurator
LeaseControl
en
Contents
Intro to SDK: Creation of Accounts and Units
  • technical_consulting

In this article, we will cover the creation of accounts and units using the Remote API. These objects are essential when working with Wialon, and their creation requires a chain of mandatory actions.

You may also find the following sources useful:

Creating an Account

Before performing this action, it is necessary to remember two important terms:

  • Creator — this is the user of the system on whose behalf this object was created.
  • Account — this is a macro-object of the system, which represents the unity of a resource, a user, and a billing plan.

Based on this, to create an account, you need to:

  1. Find a suitable billing plan.
  2. Find the system ID of the user-creator which will relate to the future account creator.
  3. Create a new user on behalf of the found user-creator.
  4. Create a resource on behalf of the new user.
  5. Merge the new user, resource, and billing plan into an account.

Let's consider the requests that will be needed at each of these steps, using the following example: it is necessary to create an account with the name sdk_account, which will be located under the account of the user manager in the service hierarchy.

1. Searching a Billing Plan

Use the request core/get_account_data.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/get_account_data&params={"type":1}&sid=SESSION_IDENTIFIER

Unlike other objects, a billing plan does not have a system ID. If it is necessary to refer to it, use its name as the unique parameter.

The names of assigned billing plans will be displayed in the response to the request in the subPlans parameter. Let's assume that we will use a billing plan with the name standard_client.

If no billing plans are displayed in the response, it is necessary to check if the account has dealer rights and if billing plans are assigned to it.

2. Searching the System ID of the User-creator

Use the request core/search_items.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"user","propName":"sys_name","propValueMask":"manager","sortType":"sys_name"},"force":1,"flags":1,"from":0,"to":0}&sid=SESSION_IDENTIFIER

Parameter and its value

Description

"itemsType":"user"

The search will be performed on users.

"propName":"sys_name"

The search will be performed on the name of the item.

"propValueMask":"manager"

The response will display the user whose name exactly matches the expression manager.

"sortType":"sys_name"

The sorting will be performed based on the name of the item.

"force":1

Previous search results will not be taken into account.

"flags":1

The response will only contain information about the general properties.

"from":0;"to":0

There will be no restrictions on the number of found items.

The system ID of the user-creator will be displayed in the response to the request in the id parameter. Let's assume it has a value of 11111.

3. Creating a New User

Use the request core/create_user.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_user&params={"creatorId":11111,"name":"sdk_account","password":"Pa%24%24w0rd","dataFlags":1}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"creatorId":11111

The new user will be created by the user with the system ID 11111.

"name":"sdk_account"

The new user will have the name sdk_account.

"password":"Pa%24%24w0rd"

The new user will have the password Pa$$w0rd.

In accordance with the security requirements, the password must contain special characters, and they must be encoded for transmission in the URL.

"dataFlags":1

Only the general properties of the new user will be displayed in the response.

The system ID of the new user will be displayed in the response to this request under the id parameter. Let's assume it has a value of 22222.

4. Creating a Resource

Use the request core/create_resource.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_resource&params={"creatorId":22222,"name":"sdk_account","dataFlags":1,"skipCreatorCheck":0}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"creatorId":22222

The new resource will be created by the user with the system ID 22222.

"name":"sdk_account"

The new resource will have the name sdk_account.

"dataFlags":1

Only the general properties of the new resource will be displayed in the response.

"skipCreatorCheck":0

Check if the user is currently the creator of any system items.

The system ID of the new resource will be displayed in the response to this request under the id parameter. Let's assume it has a value of 33333.

5. Account Merging

Use the request account/create_account.

https://hst-api.wialon.com/wialon/ajax.html?svc=account/create_account&params={"itemId":33333,"plan":"standard_client"}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"itemId":33333

The new account will contain the resource with the system ID 33333.

"plan":"standard_client"

The new account will use the standard_client billing plan.

Above, we considered only the minimum necessary steps for the creation of an account in the system. To perform other settings, additional requests from the list in the documentation should be used.


Creating a Unit

To create a unit using the Remote API, you need to:

  1. Find the system ID of the hardware type.
  2. Find the system ID of the user-creator, in whose account the future unit will be located.
  3. Create a unit.
  4. Assign a unique ID to the unit.

Let's consider the necessary requests using the following example: it is necessary to create a unit Delivery truck with the hardware type Wialon IPS and a unique ID 12345 in the account of the user sdk_account.

1. Searching the System ID of the Hardware Type

Use the request core/get_hw_types.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/get_hw_types&params={"filterType":"name","filterValue":["Wialon%20IPS"],"includeType":0,"ignoreRename":1}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"filterType":"name"

Filtering will be done by the name of the hardware type.

"filterValue":["Wialon%20IPS"]

The search will be performed by the expression Wialon IPS.

"includeType":0

The response will not show any additional information about the hardware type.

"ignoreRename":1

Renaming of the hardware types will be ignored in the response.

The system ID of the hardware type will be displayed in the response to the request in the id parameter. Let's assume it has a value of 44444.


The system ID of one hardware type may vary for different Wialon Hosting and Wialon Local services.


2. Searching the System ID of the User-creator

Use the request core/search_items.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/search_items&params={"spec":{"itemsType":"user","propName":"sys_name","propValueMask":"sdk_account","sortType":"sys_name"},"force":1,"flags":1,"from":0,"to":0}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"itemsType":"user"

The search will be performed on users.

"propName":"sys_name"

The search will be performed on the name of the item.

"propValueMask":"sdk_account"

The response will display the user whose name exactly matches the expression sdk_account.

"sortType":"sys_name"

The sorting will be performed based on the name of the item.

"force":1

Previous search results will not be taken into account.

"flags":1

The response will only contain information about the general properties.

"from":0;"to":0

There will be no restrictions on the number of found items.

The system ID of the user-creator will be displayed in the response to the request in the id parameter. Let's assume it has a value of 22222.

3. Creating a Unit

Use the request core/create_unit.

https://hst-api.wialon.com/wialon/ajax.html?svc=core/create_unit&params={"creatorId":22222,"name":"Delivery%20truck","hwTypeId":"44444","dataFlags":1}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"creatorId":22222

The user-creator of the new unit will have the system ID 22222.

"name":"Delivery%20truck"

The new unit will have the name Delivery truck.

"hwTypeId":"44444"

The system ID of the hardware type for the new unit will have a value of 44444.

"dataFlags":1

Only the general properties of the new unit will be displayed in the response.

The system ID of the unit will be displayed in the response to the request in the id parameter. Let's assume it has a value of 55555.

4. Assigning a Unique ID

Use the request unit/update_device_type.

https://hst-api.wialon.com/wialon/ajax.html?svc=unit/update_device_type&params={"itemId":55555,"deviceTypeId":"44444","uniqueId":"12345"}&sid=SESSION_IDENTIFIER
Parameter and its valueDescription
"itemId":55555

The settings will be changed for the unit with the system ID 55555.

"deviceTypeId":"44444"

The system ID of the hardware type will have a value of 44444.

Using this parameter, you can change the hardware type of the unit.

"uniqueId":"12345"

The unique ID of the unit will have a value of 12345.

Above, we considered only the minimum necessary steps for the creation of a unit in the system. To perform other settings, additional requests from the list in the documentation should be used.


Ekaterina Grib,Customer Service Engineer

If you find a mistake in the text, please select it and press Ctrl+Enter.
Thank you for your feedback!
Report a mistake
Text with the mistake Comment
Maximum 500 characters